﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm_2.Easy_303_NumArray
{
    class MainProject
    {
        static void Main(string[] args)
        {
            int[] intArray = new int[] { -2, 0, 3, -5, 2, -1 };
            NumArray numArray = new NumArray(intArray);
            Console.WriteLine(numArray.sumRange(0, 2));
            Console.WriteLine(numArray.sumRange(2, 5));
            Console.WriteLine(numArray.sumRange(0, 5));
            Console.ReadKey();
        }
    }

    public class NumArray
    {
        private int[] m_Num;
        public NumArray(int[] nums)
        {
            m_Num = nums;
        }

        public int sumRange(int i, int j)
        {
            int sum = 0;
            for (int k = i; k <= j; k++)
            {
                sum += m_Num[k];
            }
            return sum;
        }
    }
}
